package cn.tedu.v1.service.impl;

import cn.tedu.v1.model.Drug;
import cn.tedu.v1.mapper.DrugMapper;
import cn.tedu.v1.model.Store;
import cn.tedu.v1.service.IDrugService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
/**
 * <p>
 * 药品列表 服务实现类
 * </p>
 *
 * @author tedu.cn
 * @since 2021-07-06
 */
@Service
public class DrugServiceImpl extends ServiceImpl<DrugMapper, Drug> implements IDrugService {
    @Autowired
    DrugMapper drugMapper;
    @Override
    public void store(Store store) {
        if(store.getStatus()==0){//药物入库
            drugMapper.addDrug(store.getMedicine(),store.getCount());
        }else{
            drugMapper.subDrug(store.getMedicine(),store.getCount());
        }
    }

    @Override
    public List<Drug> showAllDrugs() {
        return drugMapper.selectList(null);
    }

    @Override
    public int getpriceByName(String drug) {
        return drugMapper.getpriceByName(drug);
    }
}
